import React, { useContext } from 'react'
import { MyContext } from '../../utils/index'
import GrapSon from '../GrapSon/index'
const params = '默认数据C'
const changeData = 'C改变P的默认数据'
export default function Child(props) {
    const { params, event } = useContext(MyContext)
    function changeParentData() {
        props.sendToP(changeData)

    }
    function newChange() {
        event(changeData)
    }
    return (
        <>
            <p>子组件数据:{params}</p>
            <button onClick={changeParentData}>C改变P数据</button>
            <button onClick={newChange}>C跨级改变P数据</button>
            <GrapSon />
        </>
    )
}